package com.taylover.test.hero;

/**
 * @Author xyzZero3
 * @Date 2025/4/6 21:16
 */
public class Hero {

    public String name = "1";

    public Hero() {
        name = "2";
    }

    {
        name = "3";
    }

    public static void battleWin() {
        System.out.println("hero battle win");
    }

    @Override
    public String toString() {
        return "name:" + name;
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("当前对象正在被回收");
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof Hero;
    }

    public static void main(String[] args) {
        Hero hero = new Hero();
        System.out.println(hero.name);
        // 构造方法的初始化值优先，其次代码块初始化值，最后声明时初始化值

        System.out.println(hero.equals(new ADHero()));
    }

}
